package com.lhy.security;

import com.lhy.security.annotation.GPermission;
import com.lhy.security.core.GSecurity;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class SecurityApplication {

    public static void main(String[] args) {
        SpringApplication.run(SecurityApplication.class, args);
    }

    @RequestMapping("login")
    public String test(String name){
        try{
            GSecurity.login(name, "pwd");
        }catch (Exception e){
            e.printStackTrace();
            return e.getMessage();
        }
        return "ok";
    }

    @RequestMapping("logout")
    public String test2(){
        GSecurity.logout();
        return "ok";
    }

    @GPermission("a")
    @RequestMapping("f1")
    public String test3(){
        return "f1 ok";
    }

    @GPermission("c")
    @RequestMapping("f2")
    public String test4(){
        return "f2 ok";
    }

}
